const emptyOperation = { validate() {return true;}, execute() {} };
export class ContextItem {
  constructor(id, title, operation = emptyOperation, origin) {
    this.id = id;
    this.title = title;
    this.operation = operation;
    this.origin = origin;
  }

  validate(param) {
    return this.operation.validate(this, param);
  }

  execute(params) {
    this.operation.execute(params);
  }

  setSubMenu(menuList) {
    return this.children = menuList;
  }

  highlight(params) {
    this.operation.highlight && this.operation.highlight(params);
  }

  clearHighlight(params) {
    this.operation.clearHighlight && this.operation.clearHighlight(params);
  }
}